<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<?php
include("settings/accounts.inc.php");
include("lib/util.inc.php");

echo "<h1>x-test-2.php</h1>";
echo "<br>";

$db_link = dgb_db_connect();
$query = "SELECT UserName FROM ".$DGB['DB_USERS_TABLE']."";
$result = mysql_query($query, $db_link);
$num = mysql_num_rows($result);

for ($i=0; $i<$num; $i++) {
 $data = mysql_fetch_row($result);

 if ($data[0] == "a") {
  // do nothing
 } else {
  $query1 = "SELECT COUNT(*) FROM ".$DGB['DB_TOPICS_TABLE']." WHERE PosterName like '%$data[0]%'";
  $query2 = "SELECT COUNT(*) FROM ".$DGB['DB_ANSWERS_TABLE']." WHERE PosterName like '%$data[0]%'";
  $result1 = mysql_query($query1, $db_link);
  $result2 = mysql_query($query2, $db_link);

  $data1 = mysql_fetch_row($result1);
  $data2 = mysql_fetch_row($result2);

  $query3 = "UPDATE ".$DGB['DB_USERS_TABLE']." SET TotalTopicPost = '$data1[0]' , TotalAnswerPost = '$data2[0]'  WHERE UserName = '$data[0]'";
  $result3 = mysql_query($query3, $db_link);
 }
}

echo "<br>";
echo "Done";
?>